<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>事件绑定</title>
    <script src="/javascripts/vue@3.0.11.js" ></script>
</head>
<body>

    <div id="first">
        <!-- 使用 v-on 用于绑定事件监听器 -->
        <button type="button" v-on:click="handler">点一个试试</button>
        <!-- 语法糖: v-on:eventType="eventHandler" 可以缩写为 @eventType="eventHandler" -->
        <button type="button" @click="handler">点一个试试</button>
        <p>{{ count }}</p>
    </div>

    <a href="/index.html">返回首页</a>

    <script>
        let options = {
            data(){
                return {
                    count: 0
                }
            },
            methods: {
                handler(event){
                    event.preventDefault(); // 阻止事件默认行为
                    event.stopPropagation(); // 阻止事件传播
                    console.log( this );
                    this.count++;
                }
            }
        }

        const app = Vue.createApp( options );
        app.mount( '#first' );

    </script>

</body>
</html>